﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace 健康管理系统
{
    public partial class xiugaimima : Form
    {
        public xiugaimima()
        {
            InitializeComponent();
        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void btn_xiugai_Click(object sender, EventArgs e)
        {
            if (this.txb_no.Text.Trim() == "")
            {
                MessageBox.Show("用户名不能为空！");
                this.txb_no.Focus();
                return;
            }
            if (this.txb_pwd.Text.Trim() == "")
            {
                MessageBox.Show("密码不能为空！");
                this.txb_pwd.Focus();
                return;
            }
            if (this.txb_pwd.Text.Trim() != this .txb_qrpwd .Text .Trim ())
            {
                MessageBox.Show("两次密码不一致，请重新输入！");
                this.txb_pwd.Focus();
                this.txb_qrpwd.Text  ="" ;
                this.txb_pwd .Text ="" ;
                return;
            }
            SqlConnection sqlConnection = new SqlConnection();                                          //声明并实例化SQL连接；
            sqlConnection.ConnectionString =
                "Server='DXL-D55E6339D08';Database='HealthManagementSystem';Integrated Security=sspi";                         //在字符串变量中，描述连接字符串所需的服务器地址、数据库名称、集成安全性（即是否使用Windows验证）；
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.Connection = sqlConnection;                                     //调用SQL连接的方法CreateCommand来创建SQL命令；该命令将绑定SQL连接；
            sqlCommand.CommandText =                                                                    
                "UPDATE tb_doctor"
                + " SET d_password=@Password"
                + " WHERE d_no=@No";
            sqlCommand.Parameters.AddWithValue("@Password", this.txb_pwd.Text.Trim());
            sqlCommand.Parameters.AddWithValue("@No", this.txb_no.Text.Trim());
            sqlConnection.Open();
            int rowAffected = sqlCommand.ExecuteNonQuery();
            sqlConnection.Close();
            MessageBox.Show("修改成功");                                                                   //显示提示；
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
            denglu m = new denglu();
            m.Show();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void xiugaimima_Load(object sender, EventArgs e)
        {

        }
                                                                                                                                                                
        }
  }                                                                                                    


        